local BaseWnd = require(SCRIPTS_DIR .. ".wnds.BaseWnd");
local PayWnd = class("PayWnd",BaseWnd);
function PayWnd:ctor()
	PayWnd.super.ctor(self);
	self.tradeid = 0
end

function PayWnd:onOpen()
	self.tradeid = self.wndData.param.tradeid;
	self:setClose()
	self:setBaseInfo()
end

function PayWnd:setBaseInfo()
	local name = self:widget("middle.name")
	name:setString("100W金币")
	local price = self:widget("middle.price")
	price:setString("0.01")

	local aliPay = self:widget("middle.icon_alipay")
    self:createClick({targetNode = aliPay}):clickHandler(function()
        mgrs.data:getLoginData():buyItem(self.tradeid,1)
	end);
	
	local wechatPay = self:widget("middle.icon_wechatpay")
    self:createClick({targetNode = wechatPay}):clickHandler(function()
        mgrs.data:getLoginData():buyItem(self.tradeid,2)
    end);
end

function PayWnd:onClose()
	
end

function PayWnd:setClose()
	local spbg = self:widget("middle.sp_background_1")
	spbg:setTouchEnabled(true)
	spbg:setTouchSwallowEnabled(true)

	local bgpanel = self:widget("middle.bgpanel")
	bgpanel:setTouchEnabled(true);
	bgpanel:addNodeEventListener(cc.NODE_TOUCH_EVENT,function(event)
		if event.name == "began" then
			return true;
		elseif event.name == "ended" then
			self:close()
		end
	end);
end

------------------------------------------------------------------基础类调用-----------------------------------------------------------------------------
function PayWnd:reqData(handler)
	handler(true);	
end

function PayWnd:getLayer()
	return enums.Layer.Window;
end

function PayWnd:getPreloadResList()
	return {};
end

function PayWnd:getExclusiveType()
	return 0;
end

function PayWnd:isOpenCloseSoundEnabled()
	return false;
end

function PayWnd:onEnter()
	mgrs.log:printDebug("PayWnd:onEnter");
end
function PayWnd:onExit()
	mgrs.log:printDebug("PayWnd:onExit");
end
function PayWnd:onEnterTransitionFinish()
	mgrs.log:printDebug("PayWnd:onEnterTransitionFinish");
end

function PayWnd:onExitTransitionStart()
	mgrs.log:printDebug("PayWnd:onExitTransitionStart");
end


mgrs.wnd:registerWnd(enums.Wnd.Pay,PayWnd);

--endregion
